﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

using Deep_Talk_Converter.RenderTasks;

namespace Deep_Talk_Converter
{
    /// <summary>
    /// Interaction logic for InitialPage.xaml
    /// </summary>
    public partial class InitialPage : UserControl
    {
        private MainWindow _host;

        public InitialPage(MainWindow host)
        {
            InitializeComponent();
            _host = host;
        }

        /// <summary>
        /// User wants to run us with a local rendering! Whee!
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void RenderLocally_Click(object sender, RoutedEventArgs e)
        {
            CleanURL();
            _host.SetRenderTask(new RenderLocal(textURL.Text, _host));
            _host.StartRender();
        }

        private void RenderSL_Click(object sender, RoutedEventArgs e)
        {
            CleanURL();
            RenderSL sl = new RenderSL(textURL.Text, _host);
            _host.SetRenderTask(sl);
            _host.ShowSL(sl);
        }

        /// <summary>
        /// Make sure that the URL the user has entered is "ok".
        /// </summary>
        private void CleanURL()
        {
            textURL.Text = textURL.Text.Trim();
        }

        /// <summary>
        /// Show the settings dialog, man!
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SettingsButton_Click(object sender, RoutedEventArgs e)
        {
            SettingsDialog dlg = new SettingsDialog();
            dlg.ShowDialog();
        }
    }
}
